﻿#ifndef DBMANAGER_H
#define DBMANAGER_H

#include <QObject>
#include <QSqlDatabase>
#include <QDebug>
#include <QVariant>


class DBManager : public QObject
{
    Q_OBJECT
public:
    DBManager();

    Q_INVOKABLE bool initDBManager();

    Q_INVOKABLE bool updatetUserInfo(QString, QString, QString, QString);
    Q_INVOKABLE QVariantList queryMsgDate(QString, QString);
    Q_INVOKABLE bool insertMsgDate(QString, QString, QString, QString, QString);
    Q_INVOKABLE QVariantList queryDistinctPerson(QString);
    bool insertDistinctPerson(QString, QString, QString, QString, QString, QString);
    Q_INVOKABLE QVariantList queryNewMsg(QString, QString);
    Q_INVOKABLE QVariantList queryRecNewMsg(QString, QString);
    Q_INVOKABLE QVariantList queryUserInfo(QString);
    Q_INVOKABLE bool updateMachineInfo(QString);
    Q_INVOKABLE void insertUserInfo(QString, QString, QString);
    Q_INVOKABLE bool updatePort(QString, QString);
    Q_INVOKABLE bool delPerson(QString, QString);

private:
    QSqlDatabase db;
    bool dbStatus;
};

#endif // DBMANAGER_H
